package com.example.androidkt.first

import kotlinx.coroutines.Runnable

class Lambda {

}

fun lambda() {
    val listOf = listOf("a1", "bb2", "cc2", "ddddd5", "e1")
    var max = ""
    for (zm in listOf) {
        if (zm.length > max.length) {
            max = zm
        }
    }
    println(max)
}

fun lambda1() {
    val listOf = listOf("a1", "bb2", "cc2", "ddddd5", "e1")
    val maxByOrNull = listOf.maxByOrNull { it.length }
    println(maxByOrNull)
}

fun lambda2() {
    val listOf = listOf("a1", "bb2", "cc2", "ddddd5", "e1")
    var lambda = { zm: String -> zm.length }
    var maxByOrNull = listOf.maxByOrNull(lambda)
}

fun lambda3() {
    val listOf = listOf("a1", "bb2", "cc2", "ddddd5", "e1")
    var maxByOrNull = listOf.maxByOrNull({ zm: String -> zm.length })
}

fun lambda4() {
    val listOf = listOf("a1", "bb2", "cc2", "ddddd5", "e1")
    var maxByOrNull = listOf.maxByOrNull { zm -> zm.length }
}

fun lambda5() {
    val listOf = listOf("a1", "bb2", "cc2", "ddddd5", "e1")
    var maxByOrNull = listOf.maxByOrNull { it.length }
}

fun lambda6() {
    val listOf = listOf("aa", "bbb", "c", "ddddd", "e")
    var maxByOrNull = listOf.map { it.toUpperCase() }
    for (zm in maxByOrNull) {
        println(zm)
    }
}

fun lambda7() {
    val listOf = listOf("aa", "bbb", "c", "ddddd", "e")
    var newList = listOf.map { it.toString() + "~~" }
    for (zm in newList) {
        println(zm)
    }
}

fun lambda8() {
    val listOf = listOf("aa", "bbb", "c", "ddddd", "e")
    var any = listOf.any {
        it.length > 5
    }
    var all = listOf.all { it.length > 2 }


    println(any)
    println(all)
}

var a: Int = 1;
var b: Int = 2

fun lamdbaClass() {
    Thread(object : Runnable {
        override fun run() {
            println("lamdbaClass thread start")
        }
    }).start()
}

fun lamdbaClass1() {
    Thread(Runnable {
        println("lamdbaClass thread start")
    }).start()
}

fun lamdbaClass2() {
    Thread() {
        println("lamdbaClass thread start")
    }.start()
}

fun lamdbaClass3() {
    Thread {
        println("lamdbaClass thread start")
    }.start()
}


fun main() {
    lambda8()
}